# 封装 类 接口对象层
import requests

from common.get_header import get_header
from config import EMP_ID


class DepMangerApi(object):
    # 添加
    def add_dep(self, req_head, req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                             headers=req_head, json=req_body)

        return resp

    # 查询
    def query_dep(self, dep_id, req_head):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/company/department/" + dep_id,
                            headers=req_head)

        return resp

    # 修改
    def modify_dep(self, dep_id, req_head, req_body):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/company/department/" + dep_id,
                            headers=req_head, json=req_body)
        return resp

    # 删除
    def del_dep(self, dep_id, req_head):
        resp = requests.delete(url="http://ihrm2-test.itheima.net//api/company/department/" + dep_id,
                               headers=req_head)

        return resp


# if __name__ == '__main__':
    # #添加
    # dep = DepMangerApi()
    # req_head = get_header()
    # req_body = {
    #     "name": "ICU123",
    #     "code": "13858037125"
    # }
    # resp = dep.add_dep(req_head, req_body)
    # print(resp.json())

    # # 查询
    # dep_id = EMP_ID
    # req_head = get_header()
    # dep = DepMangerApi()
    # resp = dep.query_dep(dep_id, req_head)
    # print(resp.json())

# 修改
    # dep_id = EMP_ID
    # req_head = get_header()
    # dep = DepMangerApi()
    # req_body = {
    #     "name": "ICBC",
    #     "code": "13858037125"
    # }
    # resp = dep.modify_dep(dep_id, req_head, req_body)
    # print(resp.json())

# #删除
    # dep_id = EMP_ID
    # req_head = get_header()
    # dep = DepMangerApi()
    # resp = dep.del_dep(dep_id, req_head)
    # print(resp.json())